package com.hb.trans.mvp.ui.fragment


import android.os.Bundle
import com.basiclib.base.BaseFragment
import com.hb.trans.R
import com.hb.trans.bean.TitleItem
import com.hb.trans.mvp.contract.CompanyDetailItemContract
import com.hb.trans.mvp.presenter.CompanyDetailItemPresenter
import com.hb.trans.mvp.ui.adapter.CompanyDetailItemAdapter
import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_company_item.*
import javax.inject.Inject


class CompanyDetailItemFragment : BaseFragment<CompanyDetailItemPresenter>(), CompanyDetailItemContract.View {

    override fun setViewId(): Int {
        return R.layout.fragment_company_item
    }

    @Inject
    lateinit var mAdapter: CompanyDetailItemAdapter
    @Inject
    lateinit var mPresenter: CompanyDetailItemPresenter

    val titles1: List<String> by lazy { resources.getStringArray(R.array.company_detail_title_1).toList() }
    val titles2: List<String> by lazy { resources.getStringArray(R.array.company_detail_title_2).toList() }
    private val titleList1 = ArrayList<TitleItem>()
    private val titleList2 = ArrayList<TitleItem>()

    override fun doOnInvisible() {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun doOnVisible() {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }





    override fun onFragmentInject() {
        AndroidSupportInjection.inject(this)
    }

    override fun attachView() {
//        mPresenter.attachView(this)
    }

    override fun initView() {

    }

    override fun initData() {

        var bundle: Bundle? = arguments ?: return
        var page = bundle?.getInt("page")
        when(page){
            1 -> {
                for (index in 0..titles1.size-1){
                    var title = TitleItem(titles1[index],"str")
                    titleList1.add(title)
                }


                mAdapter.setNewData(titleList1)
            }
            2 -> {
                for (index in 0..titles2.size-1){
                    var title = TitleItem(titles2[index],"str")
                    titleList2.add(title)
                }


                mAdapter.setNewData(titleList2)
            }
        }


        companyItemList.apply {
            adapter = mAdapter
        }
    }

    override fun setListener() {
//        mAdapter.setOnItemClickListener { adapter, _, position ->
//            if (position != 0) {
//                ARouter.getInstance().build(ACTIVITY_SCHOOL_INFO_COACH_INFO)
//                    .withObject("coachInfo", adapter.getItem(position))
////                    .withOptionsCompat(compat)
//                    .navigation(mContext)
//            } else {
////                ARouter.getInstance().build(ACTIVITY_NO_DETAIL).navigation()
//                showShortToast("暂未开通",SnackbarUtil.INFO)
//            }
////            var name:TextView =  adapter.getViewByPosition(companyItemList,position,R.id.teacher_name) as TextView
////            var s = name.text.toString()
////            showShortToast(name.text.toString())
//            }

    }


//    private fun showNoDataView() {
//        rlNoData.visibility = View.VISIBLE
//        companyItemList.visibility = View.GONE
//    }
//
//    private fun showDataView() {
//        rlNoData.visibility = View.GONE
//        companyItemList.visibility = View.VISIBLE
//    }
}
